#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "Core.h"


void BusClkInit(void)
{
  SOPT  = 0b01110011;
  ICGC2 = 0b01110000;
  ICGC1 = 0b01101000;
  while(ICGS1_LOCK==0);
  ICGC2_LOCRE = 1;
}

void Timer2Init(void){
  TPM2SC = 0b01000101;
}

void interrupt 14 Timer2Overflow(void){
  char s;
  s = TPM2SC;
  TPM2SC_TOF = 0;
  Core_PhyTimerInterrupt();
}

void main(void) {
 
  BusClkInit();
  Timer2Init();
  EnableInterrupts; /* enable interrupts */
  /* include your code here */

  Core_Run();

  for(;;) {
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}

